package com.eco.fanliapp.job.adminServerTask;


import com.eco.fanliapp.service.IAppCompanyService;
import com.eco.fanliapp.service.IStatisticsService;
import org.quartz.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.Serializable;

/**
 *定时出发每日数据统计
 */
@DisallowConcurrentExecution
@PersistJobDataAfterExecution
public class AdminServerOtherTask implements Job, Serializable {


    private static final Logger log = LoggerFactory.getLogger(AdminServerOtherTask.class);

    @Autowired
    private IAppCompanyService appCompanyService;

    @Autowired
    private IStatisticsService iStatisticsService;

    public AdminServerOtherTask() {}

    @Override
    public void execute(JobExecutionContext context) {

        //取得job详情
        JobDetail jobDetail = context.getJobDetail();
        JobDataMap dataMap = jobDetail.getJobDataMap();

        int executeCount = 0;
        if (dataMap.containsKey("runCount")) {
            executeCount = dataMap.getInt("runCount");
        }

        executeCount++;
        dataMap.put("runCount", executeCount);

        long startTime = System.currentTimeMillis();
        log.info("***************************************开始执行统计定时扫描任务-AdminServerOtherTask：executeCount=" + executeCount + "--startTime=" + startTime);


        try {
            //调用其它统计数据
            iStatisticsService.otherList();

        } catch (Exception e) {
            e.printStackTrace();
            log.error("执行统计定时扫描任务错误");
        }

        long endTime = System.currentTimeMillis();
        log.info("***************************************结束执行统计定时扫描任务-AdminServerOtherTask：executeCount=" + executeCount + "--endTime=" + endTime + "--耗时=" + (endTime - startTime));

    }



}
